<p>Spring <code>@Component</code>, <code>@Controller</code>, <code>@Service</code>, and <code>@Repository</code> classes are singletons by default,
meaning only one instance of the class is ever instantiated in the application. Typically such a class might have a few <code>static</code> members,
such as a logger, but all non-<code>static</code> members should be managed by Spring. That is, they should have one of these annotations:
<code>@Resource</code>, <code>@Inject</code>, <code>@Autowired</code> or <code>@Value</code>.</p>
<p>Having non-injected members in one of these classes could indicate an attempt to manage state. Because they are singletons, such an attempt is
almost guaranteed to eventually expose data from User1’s session to User2.</p>
<p>This rule raises an issue when a singleton <code>@Component</code>, <code>@Controller</code>, <code>@Service</code>, or <code>@Repository</code>,
not annotated with <code>@ConfigurationProperties</code>, has non-<code>static</code> members that are not annotated with one of:</p>
<ul>
  <li> <code>org.springframework.beans.factory.annotation.Autowired</code> </li>
  <li> <code>org.springframework.beans.factory.annotation.Value</code> </li>
  <li> <code>javax.annotation.Inject</code> </li>
  <li> <code>javax.annotation.Resource</code> </li>
</ul>
<h2>Noncompliant Code Example</h2>
<pre>
@Controller
public class HelloWorld {

  private String name = null;

  @RequestMapping("/greet", method = GET)
  public String greet(String greetee) {

    if (greetee != null) {
      this.name = greetee;
    }

    return "Hello " + this.name;  // if greetee is null, you see the previous user's data
  }
}
</pre>
<h2>See</h2>
<ul>
  <li> <a href="https://www.owasp.org/index.php/Top_10-2017_A3-Sensitive_Data_Exposure">OWASP Top 10 2017 Category A3</a> - Sensitive Data Exposure
  </li>
</ul>

